package com.group3.pojo.result;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.group3.domain.LeaveOperationResult;
import lombok.Data;

import java.util.Date;

/**
 * @ClassName OpreationResult
 * @Author WenhaoChen
 * @Date 2021/7/12 16:50
 **/
@Data
public class OperationResult {
    private String personName;

    private Integer id;

    private Integer leaveId;

    private String reasonsFailure;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
    private Date operationTime;

    private String type;

    public void setLeaveOperationResult(LeaveOperationResult leaveOperationResult){
        this.id = leaveOperationResult.getId();
        this.leaveId = leaveOperationResult.getLeaveId();
        this.reasonsFailure = leaveOperationResult.getReasonsFailure();
        this.operationTime = leaveOperationResult.getOperationTime();
        switch (leaveOperationResult.getType()){
            case 0 :
                this.type = "提交申请";
                this.personName = leaveOperationResult.getStudentName();
                break;
            case 1 :
                this.type = "通过申请";
                this.personName = leaveOperationResult.getTeacherName();
                break;
            case 2 :
                this.type = "未通过申请";
                this.personName = leaveOperationResult.getTeacherName();
                break;
            case 3 :
                this.type = "重新提交";
                this.personName = leaveOperationResult.getStudentName();
                break;
        }
    }
}
